// 获取最近的12个月
const getRecentMonths = () => {
  const monthArr = []
  const data = new Date()
  data.setMonth(data.getMonth() + 1, 1) //获取到当前月份,设置月份
  for (let i = 0; i < 12; i++) {
    data.setMonth(data.getMonth() - 1) //每次循环一次 月份值减1
    let month = data.getMonth() + 1
    month = month < 10 ? '0' + month : month
    monthArr.push(data.getFullYear() + '-' + month)
  }
  return monthArr
}

module.exports = { getRecentMonths }
